<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //阶乘函数
function jieCheng(n)
{
    var r=1 
    for(var i=1;i<=n;i++)
    {
        r=r*i
    }
    return r
}
var x  = jieCheng(4)
console.log(x);

//函数的嵌套
var a=1
function fn1()
{
    var a =2
    function fn2()
    {
        console.log("hello");
        
    }
    fn2()
}
fn1()
//回调函数
function jianBing(kouWei)
{
    var food ="煎饼"
    food= kouWei(food)
    return food
}
//自定义
function myKouWei(food)
{
    food +="香菜"
    return food
}

var bing = jianBing(myKouWei)
console.log(bing);

function NewJieCheng(n)
{
    if(n<=1)
        return 1

    return  n * NewJieCheng(n-1)
}
var ji = NewJieCheng(4)
console.log(ji);

    </script>
   